<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * PHP version 5
 *
 * Copyright 2008 The Picnic PHP Framework
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @category      Framework
 * @package       Pfw
 * @author        Sean Sitter <sean@picnicphp.com>
 * @copyright     2008 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 */
 
class Pfw_Core_HostOS {
    const OS_MAC     = 1;
    const OS_WIN     = 2;
    const OS_LINUX   = 3;
    const OS_SUNOS   = 4;
    const OS_OTHER   = 5;
    
    public static function getOS()
    {
        $uname = php_uname();
        $os = strtolower($uname);
        
        if (strpos($os, 'win') === 0) {
            return self::OS_WIN;
        } elseif (strpos($os, 'darwin') === 0) {
            return self::OS_MAC;
        } elseif (strpos($os, 'linux') === 0) {
            return self::OS_LINUX;
        } elseif (strpos($os, 'sun') === 0) {
            return self::OS_SUNOS;
        }
        
        return self::OS_OTHER;
    }
    
    public static function getHostsFilePath()
    {
        if (self::OS_WIN == self::getOS()) {
            return "C:\WINDOWS\system32\drivers\etc";
        }
        return "/etc/hosts";
    }
    
    public static function getPhpMajorVersion()
    {
        $version = PHP_VERSION;
        return $version{0};
    }
    
    public static function getPhpMinorVersion()
    {
        $version = PHP_VERSION;
        return $version{2};
    }
    
    public static function getPhpReleaseVersion()
    {
        $version = PHP_VERSION;
        return $version{4};
    }
}
